package store.lunangangster.engine.impl.calendar;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import store.lunangangster.engine.NodeFlowException;
import store.lunangangster.engine.ProcessEngineConfiguration;

public class DefaultCalendarManager {

  protected ProcessEngineConfiguration processEngineConfiguration;

  public DefaultCalendarManager(ProcessEngineConfiguration processEngineConfiguration,
      Map<String, BusinessCalendar> businessCalendarMap) {
    this.processEngineConfiguration = processEngineConfiguration;
    this.businessCalendarMap = businessCalendarMap;
  }

  protected Map<String, BusinessCalendar> businessCalendarMap = new HashMap<>();

  public Date resolveDueDate(String type, String dateString) {
    if (businessCalendarMap.containsKey(type)) {
      return businessCalendarMap.get(type).resolveDateString(dateString);
    }
    throw new NodeFlowException("不存在相应的Calendar解析器");
  }
}
